package com.baor.controller;


import com.baor.domain.FinanceVo;
import com.baor.service.CommonService;
import com.baor.service.FinanceService;
import com.baor.utils.AjaxResult;
import com.baor.utils.ExcelUtil;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
import java.io.FileOutputStream;
import java.util.List;
import java.util.Map;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;

@RestController
@RequestMapping("/common")
public class CommonController {

    @Autowired
    private CommonService commonService;

    @Autowired
    private FinanceService financeService;
    // 发送短信验证码
    @RequestMapping("/upload")
    public AjaxResult<?> upload(MultipartFile[] files){
       return commonService.upload(files);
    }

    @RequestMapping("/getImage")
    public AjaxResult<?> getImage(@RequestBody Map<String,Object> map){
        return null;
    }

    @RequestMapping("/entry")
    public AjaxResult<?> entry(@RequestBody Map<String,Object> map) {
        return commonService.entry(map);
    }

    @RequestMapping("/out")
    public AjaxResult<?> out(@RequestBody Map<String,Object> map){
        return commonService.out(map);
    }


    @RequestMapping("/export")
    public void exportExcel() throws Exception{
        List<FinanceVo> billList = (List<FinanceVo>) financeService.list().getData();
        ExcelUtil<FinanceVo> util = new ExcelUtil<>();
        String[] column = {"id","订单号","付款金额","车牌号","支付类型","时间","备注"};
        util.exportExcel("用户导出", column, billList, new FileOutputStream("E:/test.xls"), ExcelUtil.EXCEL_FILE_2003);
    }


}
